from selenium import webdriver
from selenium.webdriver.common.by import By
import time
driver=webdriver.Edge()
driver.get('http://10.59.9.14:7003/')
driver.maximize_window()
time.sleep(2)
# 点击登录按钮
driver.find_element(By.LINK_TEXT,'登录').click()
time.sleep(2)
# 输入账号密码
driver.find_element(By.NAME,'username').send_keys('18986670716')
driver.find_element(By.NAME,'password').send_keys('a123456')
time.sleep(10)
# 点击登录按钮
driver.find_element(By.CSS_SELECTOR,'.finish-btn').click()
time.sleep(5)

# 获取所有窗口句柄
all_window=driver.window_handles
# 打印获取所有窗口句柄
for i in all_window:
    print(all_window)

# 点击秒杀
driver.find_element(By.XPATH,'/html/body/div[3]/div[2]/ul/li[4]/a').click()
time.sleep(2)

# 点击商品，进入商品详情
driver.find_element(By.XPATH,'/html/body/div[5]/div[2]/div[1]/div[2]/ul/li[1]/span/a/img').click()
time.sleep(2)

# 数量修改
nums=driver.find_element(By.ID,'store_nums')
# 清除数据
nums.clear()
# 输入数据
nums.send_keys('2')
time.sleep(2)

# 点击立即购买
driver.find_element(By.XPATH,'//a[@id="buy-cart"]').click()
time.sleep(5)

# 下一步
driver.find_element(By.CLASS_NAME,'ask-btn').click()
time.sleep(5)
# 查看订单
driver.find_element(By.CLASS_NAME,'immediate-pay').click()
time.sleep(2)

